package com.ruoyi.system.service.impl;

import com.ruoyi.system.entity.SisPhase;
import com.ruoyi.system.mapper.SisPhaseMapper;
import com.ruoyi.system.service.SisPhaseService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SisPhase)表服务实现类
 *
 * @author makejava
 * @since 2023-08-01 10:18:27
 */
@Service("sisPhaseService")
public class SisPhaseServiceImpl implements SisPhaseService {
    @Resource
    private SisPhaseMapper sisPhaseMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SisPhase queryById(Integer id) {
        return this.sisPhaseMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param sisPhase 筛选条件
     * @return 查询结果
     */
    @Override
    public List<SisPhase> queryByPage(SisPhase sisPhase) {
        List<SisPhase> sisPhases = this.sisPhaseMapper.queryAllByLimit(sisPhase);
        return sisPhases;
    }

    /**
     * 新增数据
     *
     * @param sisPhase 实例对象
     * @return 实例对象
     */
    @Override
    public SisPhase insert(SisPhase sisPhase) {
        this.sisPhaseMapper.insert(sisPhase);
        return sisPhase;
    }

    /**
     * 修改数据
     *
     * @param sisPhase 实例对象
     * @return 实例对象
     */
    @Override
    public SisPhase update(SisPhase sisPhase) {
        this.sisPhaseMapper.update(sisPhase);
        return this.queryById(sisPhase.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.sisPhaseMapper.deleteById(id) > 0;
    }
}
